package com.example.bughuangkai.controller;

import com.example.bughuangkai.entity.BugHistory;
import com.example.bughuangkai.service.BugHistoryService;
import com.example.bughuangkai.vo.ReturnT;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @description bughistory
 * @author 黄凯
 * @date 2022-02-12
 */
@Controller
public class BugHistoryController {

    @Autowired
    private BugHistoryService bughistoryService;

    /**
    * 新增
    * @author 黄凯
    * @date 2022/02/12
    **/
    @PostMapping("/bughistory/insert")
    public ReturnT insert(BugHistory bughistory){
        return bughistoryService.insert(bughistory);
    }

    /**
    * 刪除
    * @author 黄凯
    * @date 2022/02/12
    **/
    @Delete("/bughistory/delete")
    public ReturnT<String> delete(int id){
        return bughistoryService.delete(id);
    }

    /**
    * 更新
    * @author 黄凯
    * @date 2022/02/12
    **/
    @RequestMapping("/bughistory/update")
    public ReturnT<String> update(BugHistory bughistory){
        return bughistoryService.update(bughistory);
    }

    /**
    * 查询 根据主键 id 查询
    * @author 黄凯
    * @date 2022/02/12
    **/
    @ResponseBody
    @GetMapping("/bughistory/load")
    public Object load(int id){
        return bughistoryService.load(id);
    }

    /**
    * 查询 分页查询
    * @author 黄凯
    * @date 2022/02/12
    **/
    @RequestMapping("/bughistory/pageList")
    public Map<String, Object> pageList(@RequestParam(required = false, defaultValue = "0") int offset,
                                        @RequestParam(required = false, defaultValue = "10") int pagesize) {
        return bughistoryService.pageList(offset, pagesize);
    }

}